package com.hnucm.cooklife.model;

import com.hnucm.cooklife.base.BaseModel;
import com.hnucm.cooklife.bean.me.DishColl;
import com.hnucm.cooklife.contract.realDish.Contract;

import java.util.ArrayList;
import java.util.List;

import io.reactivex.Observable;

public class RealDishModel extends BaseModel implements Contract.IRealDishModel {
    public RealDishModel() {
        setCookies(false);
    }

    @Override
    public Observable<List<DishColl>> loadRealMyDish(int userid) {
        return mApiServer.loadRealMyDish(userid)
                .map(realDishData -> {
                    List<DishColl> dishCollList = new ArrayList<>();
                    realDishData.getData().stream().forEach(dataDTO -> {
                        DishColl dishColl = new DishColl();
                        dishColl.dishId = dataDTO.getDishId();
                        dishColl.dishdone = dataDTO.getDishdone();
                        dishColl.dishscore = dataDTO.getDishscore();
                        dishColl.dishpic = dataDTO.getDishpic();
                        dishColl.dishname = dataDTO.getDishname();
                        dishColl.collect = dataDTO.getCollect();
                        dishColl.dishdesc = dataDTO.getDishdesc();
                        dishColl.icon = dataDTO.getIcon();
                        dishColl.userid = dataDTO.getUserid();
                        dishCollList.add(dishColl);
                    });
                    return dishCollList;
                });
    }

    @Override
    public Observable<List<DishColl>> refreshRealMyDish(int userid) {
        return null;
    }
}
